package com.snack.controller;

import com.snack.common.result.Result;
import com.snack.entity.pojo.Category;
import com.snack.service.CategoryService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @author huangfuhao
 * @Date 2025/3/28
 */
@RestController
@RequestMapping("/api/category")
public class CategoryController {

    @Resource
    private CategoryService categoryService;

    //新增分类
    @PostMapping("/addCategory")
    public Result addCategory(@RequestBody Category category){
        return categoryService.addCategory(category);
    }

    //删除分类
    @PostMapping("/deleteCategory")
    public Result deleteCategory(@RequestBody Category category){
        return categoryService.deleteCategory(category);
    }

    //获取分类列表
    @GetMapping("/listCategory")
    public Result listCategory(){
        return categoryService.listCategory();
    }
}
